<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AddressStoreRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return auth('api')->check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'province'=>'required',
            'city'=>'required',
            'name'=>'required',
            'phone_number'=>['required','regex:/^1[345789][0-9]{9}$/']
        ];
    }
    public function messages()
    {
        return [
            'province.required'=>"请选择省份",
            "city.required"=>"请选择城市",
            "name.required"=>"请输入收货人姓名",
            "phone_number.required"=>"请输入收货人联系方式",
            "phone_number.regex"=>"手机号格式错误"
        ];
    }
}
